package easystudy.admin;

import java.util.List;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpSession;

import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.servlet.ModelAndView;

import easystudy.dao.BoardDao;
import easystudy.dto.Board;

@Controller
public class IntroController {
	
	private BoardDao boardDao;
	
	public void setBoardDao(BoardDao boardDao){
		this.boardDao = boardDao;
	}
	
	@RequestMapping(value="/intro.ad")
	protected ModelAndView doIntroProcess(HttpServletRequest req){
		HttpSession session = req.getSession();
		session.setAttribute("keyword","");
		session.setAttribute("num",0);
		session.setAttribute("byhit",0);
		
		List<Board> noticeList = boardDao.getNoticeList(1, 10);
		
		List<Board> hitcountList = boardDao.getBoardListByHit(1, 10);
				
		List<Board> normalList = boardDao.getBoardList(1, 10);
		
		ModelAndView mav = new ModelAndView();
		
		mav.setViewName("base");
		mav.addObject("noticeList",noticeList);
		mav.addObject("hitcountList",hitcountList);
		mav.addObject("normalList",normalList);	
		return mav;
	}

}
